package com.yonyou.trumpchi.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yonyou.trumpchi.R;
import com.yonyou.trumpchi.entity.ServiceInfo;

import java.util.List;

/**
 * @author liuxiaopeng
 * @version V1.0.0
 * @time 2016/11/25
 * @describe
 */

public class ServiceAdapter extends BaseAdapter {

    private List<ServiceInfo> mList;
    private LayoutInflater mInflater;

    public ServiceAdapter(List<ServiceInfo> mList, LayoutInflater mInflater) {
        this.mList = mList;
        this.mInflater = mInflater;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        final ServiceInfo item = mList.get(i);
        ViewHoder hoder = null;
        if (null == view) {
            view = mInflater.inflate(R.layout.item_service, null);
            hoder = new ViewHoder();
            hoder.textView = (TextView) view.findViewById(R.id.tv_item_service_name);
            view.setTag(hoder);
        } else {
            hoder = (ViewHoder) view.getTag();
        }

        hoder.textView.setText(item.getName());
        return view;
    }


    static class ViewHoder {
        TextView textView;
    }

}
